package trabajoISW2.presentation.shared;

import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

public class CartDTO {
	
	private List<DetailDTO> details = new LinkedList<DetailDTO>();
	private double amount;
	
	public CartDTO(List<DetailDTO> d, double am){
		details = d;
		setAmount(am);
	}
	
	public void setDetails(List<DetailDTO> details) {
		this.details = details;
	}
	public List<DetailDTO> getDetails() {
		return details;
	}

	public void setAmount(double amount) {
		this.amount = amount;
	}

	public double getAmount() {
		return amount;
	}
	
	public double calculateAmount(List<DetailDTO> details) {
		Iterator<DetailDTO> it = details.iterator();
		DetailDTO d;
		double res = 0;
		while (it.hasNext()) {
			d = it.next();
			res += d.getBook().getPrice() * d.getQuantity();
		}
		return res;

	}

}
